/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package xmlutils;

import java.util.Vector;
import org.kxml.Xml;
import org.kxml.kdom.Element;

/**
 *
 * @author Ayman
 */
public class ZoomLevelData {

    private String singleUrl = "";  // for zoomlevel without loops
    private Vector loops = new Vector(5);    // for zoomlevel that contains loops

    public ZoomLevelData(Element zoomLevelElement) {
        if (zoomLevelElement != null) {
            if(zoomLevelElement.getChildCount() > 1)
            {  //contains nested elements (loops)
                int elementsCount = zoomLevelElement.getChildCount();
                int elementType = -1;

                for (int i = 0; i < elementsCount; i++) {
                    elementType = zoomLevelElement.getType(i);
                    if (elementType != Xml.ELEMENT) {
                        continue;
                    }
                    loops.addElement(new LoopData(zoomLevelElement.getElement(i)));
                }
            } else {    // contains text (singleurl)
                singleUrl = zoomLevelElement.getText();
            }
        }
    }

    public String getImageURL() {
        return singleUrl;
    }

    public LoopData getLoopAt(int i) {
        return (LoopData) loops.elementAt(i);
    }

    public int getLoopsSize() {
        return loops.size();
    }
}
